
if exists(select name from sysobjects where name = 'sp_MenuGetMenuChaByUserId')
	drop proc sp_MenuGetMenuChaByUserId
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_MenuCheckQuyenVaoTrang.sql
*/

create proc sp_MenuGetMenuChaByUserId
@Userid int
as
begin
	declare @NhomUserID int
	set @NhomUserID=(select NhomUserid from Users where Userid=@Userid)
	if(@NhomUserID=1)
		begin
			select * from tbl_menus where menuchaid=0 and trangthai<>255 order by thutu
		end
	else
		begin
			select a.* from tbl_menus a inner join tbl_nhomuser_menu b on a.menuid=b.menuid and a.menuchaid=0 inner join Users c on b.nhomuserid=c.NhomUserId and c.Userid=@Userid order by a.thutu
		end
end

